package com.weiai.wedding.entity.file;



import java.io.Serializable;
import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.persistence.Transient;
import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;
import org.springframework.format.annotation.DateTimeFormat;

import com.weiai.wedding.util.JedisKey;
@Entity
@Table(name="user_file")
@Cache(usage=CacheConcurrencyStrategy.READ_WRITE)
public class UserFile implements Serializable{ 
	/**
	 * 
	 */
	private static final long serialVersionUID = -5961661545448006131L;

	/**
	 * id
	 */
	private String id;
	
	/**
	 * 用户ID
	 */
	private String userId;
	/**
	 * 用户ip地址
	 */
	private String ip;
	
	/**
	 * 文件名
	 */
	private String fileName;
	
	private String beforeFileName;
	
	private String afterFileName;
	/**
	 * 文件后缀
	 */
	private String fileSuffix;
	/**
	 * 文件大小
	 */
	//private long fileSize;
	/**
	 * 域名
	 */
	private String domain;
	/**
	 * 目标路径
	 */
	private String downloadUrl;
	/**
	 * 上传路径
	 */
	private String uploadPath;
	/**
	 * 创建人
	 */
	private String createdBy;
	/**
	 * 创建时间
	 */
	@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
	private Date createdTime;
	
	@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
	private Date beginCreatedTime;
	@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
	private Date endCreatedTime;
	/**
	 * 修改人
	 */
	private String modifyBy;
	/**
	 * 修改时间
	 */
	@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
	private Date modifyTime;
	
	@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
	private Date beginModifyTime;
	@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
	private Date endModifyTime;
	
	private String source;
	
	private String status;
	public UserFile(){}
	
	@Id
	@GeneratedValue(strategy=GenerationType.IDENTITY)
	public String getId() {
		return id;
	}
	public void setId(String id) {
		this.id = id;
	}
	
	@Column(nullable=false,length=10)
	public String getUserId() {
		return userId;
	}
	public void setUserId(String userId) {
		this.userId = userId;
	}
	@Column(nullable=false,length=200)
	public String getFileName() {
		return fileName;
	}
	public void setFileName(String fileName) {
		this.fileName = fileName;
	}
	@Column(nullable=false,length=200)
	public String getAfterFileName() {
		return afterFileName;
	}

	public void setAfterFileName(String afterFileName) {
		this.afterFileName = afterFileName;
	}

	@Column(nullable=false,length=30)
	public String getFileSuffix() {
		return fileSuffix;
	}
	public void setFileSuffix(String fileSuffix) {
		this.fileSuffix = fileSuffix;
	}
	
//	@Column(nullable=false)
//	public long getFileSize() {
//		return fileSize;
//	}
//	public void setFileSize(long fileSize) {
//		this.fileSize = fileSize;
//	}
	
	@Column(nullable=false,length=2000)
	public String getDownloadUrl() {
		return downloadUrl;
	}
	public void setDownloadUrl(String downloadUrl) {
		this.downloadUrl = downloadUrl;
	}
	
	
	@Column(nullable=false)
	@Temporal(TemporalType.TIMESTAMP)
	public Date getCreatedTime() {
		return createdTime;
	}
	public void setCreatedTime(Date createdTime) {
		this.createdTime = createdTime;
	}
	

	@Column
	@Temporal(TemporalType.TIMESTAMP)
	public Date getModifyTime() {
		return modifyTime;
	}
	public void setModifyTime(Date modifyTime) {
		this.modifyTime = modifyTime;
	}
	@Column(nullable=false,length=512)
	public String getUploadPath() {
		return uploadPath;
	}
	public void setUploadPath(String uploadPath) {
		this.uploadPath = uploadPath;
	}
	
	@Column(nullable=false,length=30)
	public String getIp() {
		return ip;
	}

	public void setIp(String ip) {
		this.ip = ip;
	}
	@Column(nullable=false,length=512)
	public String getDomain() {
		return domain;
	}

	public void setDomain(String domain) {
		this.domain = domain;
	}
	@Column
	public String getSource() {
		return source;
	}

	public void setSource(String source) {
		this.source = source;
	}
	@Column(nullable=false,length=200)
	public String getBeforeFileName() {
		return beforeFileName;
	}

	public void setBeforeFileName(String beforeFileName) {
		this.beforeFileName = beforeFileName;
	}
	
	
	public String getCreatedBy() {
		return createdBy;
	}

	public void setCreatedBy(String createdBy) {
		this.createdBy = createdBy;
	}

	public String getModifyBy() {
		return modifyBy;
	}

	public void setModifyBy(String modifyBy) {
		this.modifyBy = modifyBy;
	}

	public String getStatus() {
		return status;
	}

	public void setStatus(String status) {
		this.status = status;
	}

	@Transient
	public Date getBeginModifyTime() {
		return beginModifyTime;
	}

	public void setBeginModifyTime(Date beginModifyTime) {
		this.beginModifyTime = beginModifyTime;
	}
	@Transient
	public Date getEndModifyTime() {
		return endModifyTime;
	}

	public void setEndModifyTime(Date endModifyTime) {
		this.endModifyTime = endModifyTime;
	}

	@Transient
	public Date getBeginCreatedTime() {
		return beginCreatedTime;
	}

	public void setBeginCreatedTime(Date beginCreatedTime) {
		this.beginCreatedTime = beginCreatedTime;
	}
	@Transient
	public Date getEndCreatedTime() {
		return endCreatedTime;
	}

	public void setEndCreatedTime(Date endCreatedTime) {
		this.endCreatedTime = endCreatedTime;
	}

	/**
	 * 如果需要，则返回redis中的key值，用来保存这个对象，以hash的形式
	 */
	@Override
	public String toString() {
		return JedisKey.PALTFORM_HASH_FILE_ID_KEY+this.getId();
	}
}
